import React, { useState, useEffect } from 'react';
import styles from './index.less';
import { Upload, message, Button } from 'antd';
import { connect } from 'umi';
import { PlusOutlined } from '@ant-design/icons';
var apiUrl = process.env.apiUrl;

var UploadComp = props => {
  return (
    <div>
      <Upload
        listType="picture-card"
        action={`${apiUrl}/vessel/readTemplate`}
        onChange={file => {
          console.log(file);
          if (file.file.status === 'done') {
            message.success('上传成功');
            props.init();
          }
        }}
      >
        {
          <div>
            <PlusOutlined />
            <div style={{ marginTop: 8 }}>Upload</div>
          </div>
        }
      </Upload>

      <div>
        <Button
          type="primary"
          onClick={() => {
            props.init();
          }}
        >
          刷新
        </Button>
      </div>
    </div>
  );
};

export default connect(({}) => ({}))(UploadComp);
